<?php

namespace app\api\controller;

use app\api\model\Good as ModelGood;
use app\api\model\User;
use app\common\LogService;
use app\common\ScoreLog;
use think\facade\Db;

class Good extends Base
{
    public function list()
    {
        // -1 全部
        $type = input('type', '-1');
        $arr = ['-1', '1', '2', '3'];
        if (!in_array($type, $arr)) {
            return error();
        }
        $list = ModelGood::list($type);
        return success($list);
    }
    public function detail($id)
    {
        $data = ModelGood::where(['status' => 1])->find($id);
        if (!$data) {
            return error('商品不存在');
        }
        return success($data);
    }
    public function pay($id)
    {
        $res = (new ModelGood())->pay($id);
        if ($res) return success($res);
        return error();
    }
}
